package lzy.service.impl;

import lzy.entity.QualityInspection;
import lzy.mapper.QualityInspectionMapper;
import lzy.service.QualityInspectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class QualityInspectionServiceImpl implements QualityInspectionService {
    @Autowired
    private QualityInspectionMapper mapper;

    @Override
    public List<QualityInspection> findAll() {
        return mapper.findAll();
    }

    @Override
    public int insert(QualityInspection inspection) {
        if (inspection.getInspectType() == null) inspection.setInspectType("初质检");
        if (inspection.getResult() == null) inspection.setResult("未通过");
        return mapper.insert(inspection);
    }

    @Override
    public List<QualityInspection> findByBatchNo(String batchNo) {
        return mapper.findByBatchNo(batchNo);
    }

    @Override
    public List<QualityInspection> findByFilter(String batchNo, String inspectType, String startTime, String endTime) {
        return mapper.findByFilter(batchNo, inspectType, startTime, endTime);
    }

    @Override
    public int countInLastDays(int days) {
        return mapper.countInLastDays(days);
    }

    @Override
    public int countAll() {
        return mapper.countAll();
    }

    @Override
    public int countByResult(String result) {
        return mapper.countByResult(result);
    }
} 